﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.MovieRecorder.SystemRootValidationRule
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Globalization;
using System.IO;
using System.Windows.Controls;


namespace DnProcessSimulateCommands.MovieRecorder;

public class SystemRootValidationRule : ValidationRule
{
  public ValidationParams Param { get; set; }

  public override ValidationResult Validate(object value, CultureInfo cultureInfo)
  {
    bool isValid = false;
    string path = value as string;
    if (this.Param.IsActive)
    {
      if (!string.IsNullOrEmpty(path))
      {
        if (path.Length > 1)
        {
          try
          {
            if (Path.IsPathRooted(path))
              isValid = new DirectoryInfo(path).Exists;
          }
          catch
          {
            isValid = false;
          }
        }
      }
    }
    else
      isValid = true;
    return new ValidationResult(isValid, (object) null);
  }
}
